<?
require_once("lib/php/controller/ViewController.php");
require_once("ericdingle/php/Authentication.php");

class Admin extends ViewController {
	private $auth_;

	public function __construct() {
		$this->auth_ = Authentication::getInstance();
	}
	
	public function doGet() {
		$logout = $_GET["logout"];
		if ($logout == "true") {
			$this->auth_->logout();
			header("Location: viewPosts");
			exit();
		}
		
		require_once("ericdingle/php/Tabs.php");
		$this->loadView("ericdingle/view/header.php", array(
			"isLoggedIn" => $this->auth_->isLoggedIn(),
			"tabs" => $tabs,
			"js_files" => array("js/admin.js")
		));
		$this->loadView("ericdingle/view/admin.php");
		$this->loadView("ericdingle/view/footer.php");
	}
	
	public function doPost() {
		$password = $_POST["password"];
		if ($this->auth_->login($password)) {
			header("Location: viewPosts");
			exit();
		}
		
		$this->doGet();
	}
};
?>
